package com.example.easy.Controller;


import com.example.easy.Dto.Infobar;
import com.example.easy.Dto.Notice;
import com.example.easy.Service.myservice.InfobarServise;
import com.example.easy.Service.myservice.NoticeServise;
import com.example.easy.Tools.ResultCode;
import com.example.easy.mapper.InfobarMapper;
import com.example.easy.mapper.NoticeMapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

@Scope("prototype")
@RestController
@Api(value = "Infobar", description = "信息栏管理")
@RequestMapping(value = "/infobar")

public class InfobarController {


    @Autowired
    InfobarServise infobarServise;

    @Autowired
    InfobarMapper infobarMapper;

    @ApiOperation(value = "增加信息", notes = "增加信息")
    @RequestMapping(value = "/insinfobar", method = RequestMethod.POST, produces = "application/json;charset=utf-8")
    public Object insInfobar(@RequestBody Infobar infobar) throws IOException {

        return ResultCode.SUCCESS.result(infobarServise.insInfobar(infobar));

    }

    @ApiOperation(value = "修改信息", notes = "修改信息")
    @RequestMapping(value = "/updateNotice", method = RequestMethod.POST, produces = "application/json;charset=utf-8")
    public Object updateInfobar(@RequestBody Infobar infobar) throws IOException {

        return ResultCode.SUCCESS.result(infobarServise.updateInfobar(infobar));

    }

    @ApiOperation(value = "删除信息", notes = "删除信息")
    @RequestMapping(value = "/deleteNotice", method = RequestMethod.POST, produces = "application/json;charset=utf-8")
    public Object deleteInfobar(@RequestBody int number) throws IOException {

        return ResultCode.SUCCESS.result(infobarServise.deleteInfobar(number));

    }

    @ApiOperation(value = "查看信息", notes = "查看信息")
    @RequestMapping(value = "/selectnotice", method = RequestMethod.POST, produces = "application/json;charset=utf-8")
    public Object selectInfobar(@RequestBody int number) throws IOException {

        return ResultCode.SUCCESS.result(infobarServise.selectInfobar(number));

    }

    @ApiOperation(value = "查看所有信息", notes = "查看所有信息")
    @RequestMapping(value = "/selectall", method = RequestMethod.POST, produces = "application/json;charset=utf-8")
    public Object selectall() throws IOException {

        return ResultCode.SUCCESS.result(infobarServise.selectall());

    }

}
